﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using wUniAppPCL;

namespace wUniApp.Controls
{
  public partial class wMessage : wBaseMessage
  {

    public override async Task<wMessageDlgResultEnum> Show(string message, wMessageDlgTypeEnum type, string title = "")
    {
      var res = wMessageDlgResultEnum.Cancel;
      var dispatcher = System.Windows.Application.Current.Dispatcher;
      await dispatcher.InvokeAsync(new Action(() =>
      {
        var dlgResult = MessageBoxResult.Cancel;
        switch (type)
        {
          case wMessageDlgTypeEnum.YesNo:
            {
              dlgResult = MessageBox.Show(message, title, MessageBoxButton.YesNo);
              break;
            }
          case wMessageDlgTypeEnum.OK:
            {
              MessageBox.Show(message, title, MessageBoxButton.OK);
              dlgResult = MessageBoxResult.OK;
              break;
            }
        }
        res = (dlgResult == MessageBoxResult.Yes) ? wMessageDlgResultEnum.Yes : wMessageDlgResultEnum.No;
      }));
      return res;
    }
  }
}
